package com.yc.demo.d0729;

import com.yc.demo.util.VerifyCodeUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "VcodeServlet", value = "/vcode.s")
public class VcodeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        final HttpSession session = request.getSession();
        // 生成验证码同时返回验证码字符串
        final String vcode = VerifyCodeUtils.outputImage(response);
        // 将验证码写入会话
        session.setAttribute("vcode", vcode);

    }

}
